import { ResPage } from '@/api/interface'
import { CommandCenter } from './interface'
import { TBY } from '@/api/config/servicePort'
import http from '@/api'

export const pageCommandCenter = (params: CommandCenter.Query) => {
  return http.get<ResPage<CommandCenter.Record>>(TBY + `/command_center/page`, params)
}

export const listCommandCenter = (params: CommandCenter.Query) => {
  return http.get<CommandCenter.Record[]>(TBY + `/command_center/list`, params)
}

// 山峰详情
export const getCommandCenterDetail = (id: number) => {
  return http.get<Partial<CommandCenter.Form>>(TBY + `/command_center/get`, { id }, { loading: false })
}

// 新增或修改山峰
export const saveOrUpdateCommandCenter = (params: Partial<CommandCenter.Form>) => {
  return http.post(TBY + `/command_center/save`, params)
}

// 删除山峰
export const removeCommandCenter = (id: number) => {
  return http.delete(TBY + `/command_center/delete`, { id })
}

/**查询智能箱 */
export const pageCommandCenterBox = (params: CommandCenter.Query) => {
  return http.get<ResPage<CommandCenter.BoxRecord>>(TBY + `/command_center/box_page`, params)
}

/**保存智能箱关系 */
export const saveCommandCenterBox = (data: CommandCenter.BoxRecord) => {
  return http.post(TBY + `/command_center/box_save`, data)
}
